import '../reommend_data.dart';
import 'AboutMsj.dart';
import 'AdvancedSkill.dart';
import 'CookStep.dart';
import 'CoverImg.dart';
import 'MainIngredient.dart';
import 'SecondaryIngredient.dart';
import 'Share.dart';
import 'ShopInfo.dart';

class MealDetailData {
  AboutMsj? about_msj;
  List<AdvancedSkill>? advanced_skills;
  String? amount;
  Author? author;
  String? caloric;
  var comment_amount;
  String? comment_amount_new;
  List<CookStep>? cook_steps;
  String? cooking_time;
  CoverImg? cover_img;
  String? favor_amount;
  String? favor_amount_new;
  String? id;
  String? is_favored;
  String? is_zan;
  List<MainIngredient>? main_ingredient;
  String? rate;
  String? recipe_long_img;
  String? recipe_long_img_pre;
  String? recipe_type;
  List<SecondaryIngredient>? secondary_ingredient;
  Share? share;
  String? share_amount;
  ShopInfo? shop_info;
  String? story_content;
  String? taste;
  String? technology;
  String? title;
  String? viewed_amount;
  String? zan_num;

  MealDetailData(
      {this.about_msj,
      this.advanced_skills,
      this.amount,
      this.author,
      this.caloric,
      this.comment_amount,
      this.comment_amount_new,
      this.cook_steps,
      this.cooking_time,
      this.cover_img,
      this.favor_amount,
      this.favor_amount_new,
      this.id,
      this.is_favored,
      this.is_zan,
      this.main_ingredient,
      this.rate,
      this.recipe_long_img,
      this.recipe_long_img_pre,
      this.recipe_type,
      this.secondary_ingredient,
      this.share,
      this.share_amount,
      this.shop_info,
      this.story_content,
      this.taste,
      this.technology,
      this.title,
      this.viewed_amount,
      this.zan_num});

  factory MealDetailData.fromJson(Map<String, dynamic> json) {
    return MealDetailData(
      about_msj: json['about_msj'] != null
          ? AboutMsj.fromJson(json['about_msj'])
          : null,
      advanced_skills: json['advanced_skills'] != null
          ? (json['advanced_skills'] as List)
              .map((i) => AdvancedSkill.fromJson(i))
              .toList()
          : null,
      amount: json['amount'],
      author: json['author'] != null ? Author.fromJson(json['author']) : null,
      caloric: json['caloric'],
      comment_amount: json['comment_amount'],
      comment_amount_new: json['comment_amount_new'],
      cook_steps: json['cook_steps'] != null
          ? (json['cook_steps'] as List)
              .map((i) => CookStep.fromJson(i))
              .toList()
          : null,
      cooking_time: json['cooking_time'],
      cover_img: json['cover_img'] != null
          ? CoverImg.fromJson(json['cover_img'])
          : null,
      favor_amount: json['favor_amount'],
      favor_amount_new: json['favor_amount_new'],
      id: json['id'],
      is_favored: json['is_favored'],
      is_zan: json['is_zan'],
      main_ingredient: json['main_ingredient'] != null
          ? (json['main_ingredient'] as List)
              .map((i) => MainIngredient.fromJson(i))
              .toList()
          : null,
      rate: json['rate'],
      recipe_long_img: json['recipe_long_img'],
      recipe_long_img_pre: json['recipe_long_img_pre'],
      recipe_type: json['recipe_type'],
      secondary_ingredient: json['secondary_ingredient'] != null
          ? (json['secondary_ingredient'] as List)
              .map((i) => SecondaryIngredient.fromJson(i))
              .toList()
          : null,
      share: json['share'] != null ? Share.fromJson(json['share']) : null,
      share_amount: json['share_amount'],
      shop_info: json['shop_info'] != null
          ? ShopInfo.fromJson(json['shop_info'])
          : null,
      story_content: json['story_content'],
      taste: json['taste'],
      technology: json['technology'],
      title: json['title'],
      viewed_amount: json['viewed_amount'],
      zan_num: json['zan_num'],
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['amount'] = this.amount;
    data['caloric'] = this.caloric;
    data['comment_amount'] = this.comment_amount;
    data['comment_amount_new'] = this.comment_amount_new;
    data['cooking_time'] = this.cooking_time;
    data['favor_amount'] = this.favor_amount;
    data['favor_amount_new'] = this.favor_amount_new;
    data['id'] = this.id;
    data['is_favored'] = this.is_favored;
    data['is_zan'] = this.is_zan;
    data['rate'] = this.rate;
    data['recipe_long_img'] = this.recipe_long_img;
    data['recipe_long_img_pre'] = this.recipe_long_img_pre;
    data['recipe_type'] = this.recipe_type;
    data['share_amount'] = this.share_amount;
    data['story_content'] = this.story_content;
    data['taste'] = this.taste;
    data['technology'] = this.technology;
    data['title'] = this.title;
    data['viewed_amount'] = this.viewed_amount;
    data['zan_num'] = this.zan_num;
    if (this.about_msj != null) {
      data['about_msj'] = this.about_msj!.toJson();
    }
    if (this.advanced_skills != null) {
      data['advanced_skills'] =
          this.advanced_skills!.map((v) => v.toJson()).toList();
    }
    if (this.author != null) {
      data['author'] = this.author!.toJson();
    }
    if (this.cook_steps != null) {
      data['cook_steps'] = this.cook_steps!.map((v) => v.toJson()).toList();
    }
    if (this.cover_img != null) {
      data['cover_img'] = this.cover_img!.toJson();
    }
    if (this.main_ingredient != null) {
      data['main_ingredient'] =
          this.main_ingredient!.map((v) => v.toJson()).toList();
    }
    if (this.secondary_ingredient != null) {
      data['secondary_ingredient'] =
          this.secondary_ingredient!.map((v) => v.toJson()).toList();
    }
    if (this.share != null) {
      data['share'] = this.share!.toJson();
    }
    if (this.shop_info != null) {
      data['shop_info'] = this.shop_info!.toJson();
    }
    return data;
  }
}
